package beike;

import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

/**
 * @author zhangmin
 * @create 2022-03-21 18:38
 */
public class Main3 {
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int n=cin.nextInt();
        cin.nextLine();
        String str=cin.nextLine();
        String[] lines=new String[n];
        char[][] linechar=new char[n][n];
        long res=0;
        for (int i = 0; i < n; i++) {
            lines[i]=cin.nextLine();
            linechar[i]=lines[i].toCharArray();
        }
        for (int i = 0; i < n; i++) {
            String line=lines[i];
            int index=0;
            while (index<line.length())
            {
                int i1 = line.indexOf(str, index);
                if (i1!=-1){
                    res++;
                    index=i1+str.length();
                }
            }

        }
        for (int i = 0; i < n; i++) {
            StringBuffer sb=new StringBuffer();
            for (int j = 0; j < n; j++) {
                sb.append(linechar[j][i]);
            }
            String line=sb.toString();
            int index=0;
            while (index<line.length())
            {
                int i1 = line.indexOf(str, index);
                if (i1!=-1){
                    res++;
                    index=i1+str.length();
                }
            }
        }
        System.out.println(res);
    }
}
